function log_like = LogLikelihood_years(param)

%% GLOBAL

global Y T1 T2 SM SR Draws M ll


%% PARAM def 

gamma1=param(1);
gamma2=param(2);
cy=param(3);
c1=param(4);
c2=param(5);
phi1=param(6);
phi2=param(7);
cm=param(8);
cr=param(9);
phim=param(10);
phir=param(11);
sigtheta=param(12);
sige1 = param(13);
sige2 = param(14);
sigem = param(15);
siger = param(16);
sigy=param(17);






%%

theta = Draws*sigtheta;

Lsm = normalpdf(repmat(SM,1,M)-cm-phim*theta,0,sigem);
Lsr = normalpdf(repmat(SR,1,M)-cr-phir*theta,0,siger);
Lt1 = normalpdf(repmat(T1,1,M)-c1-phi1*theta,0,sige1);
Lt2 = normalpdf(repmat(T2,1,M)-c2-phi2*theta,0,sige2);

%% Bias

b1 = repmat(T1,1,M)-cy-theta;
b2 = repmat(T2,1,M)-cy-theta;

% Y

Ly = normalpdf(repmat(Y,1,M)-cy-theta-gamma1*b1-gamma2*b2,0,sigy);

%% Individual Likelihood Contribution
Lm=((((Lsm.*Lsr).*Lt1).*Lt2).*Ly);

%% log likelihood
ll = (log(mean(Lm,2)));
log_like = -sum(log(mean(Lm,2)));